﻿using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Input.Touch;
using ProtectThePieWP7.AdditionalClasses;
using Microsoft.Xna.Framework.Input;
using ThreeThingGame;

namespace ProtectThePie
{
    public enum PauseMenuState
    {
        mainMenu,
        options
    }

    public class Pause
    {
        private Point fieldSize;
        private PauseMenuState state;
        private MenuSystem menu;
        private MenuSystem optionsMenu;

        public Pause(Point fieldSize)
        {
            this.fieldSize = fieldSize;
            this.state = PauseMenuState.mainMenu;

            menu = new MenuSystem(Game1.menuClick, Game1.menuTexture);
            optionsMenu = new MenuSystem(Game1.menuClick, Game1.menuTexture);

            menu.AddMenuEntry("Continue", MenuEntryType.link);
            menu.AddMenuEntry("Main Menu", MenuEntryType.link);
        }

        public bool Draw(SpriteBatch spriteBatch)
        {
            //Draw Menu Entries
            switch (state)
            {
                case PauseMenuState.mainMenu:
                    menu.Draw(spriteBatch);
                    break;
                case PauseMenuState.options:
                    optionsMenu.Draw(spriteBatch);
                    break;
            }

            return true;
        }

        public bool Update(TouchCollection touches)
        {
            // Allows the game to exit
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
                Game1.exit = true;

            //Update Menu
            switch (state)
            {
                case PauseMenuState.mainMenu:
                    switch (menu.Update(touches))
                    {
                        case "Continue":
                            Game1.state = GameState.GamePlay;
                            break;
                        case "Main Menu":
                            Game1.state = GameState.MainMenu;
                            break;
                        case "":
                            break;
                    }
                    break;
            }


            return true;
        }
    }
}
